package com.leo.tool.jdk.jdk9;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.SubmissionPublisher;

public class RxJava {

    public static void main(String[] args) throws InterruptedException {
        CompletableFuture<Void> consume;
        try (SubmissionPublisher<Integer> publisher = new SubmissionPublisher<>()) {
            consume = publisher.consume(System.out::println);
            consume.thenAccept(t -> System.out.println("completed"));
            publisher.submit(1);
            publisher.submit(2);
            publisher.submit(3);
        }
        consume.join();
    }
}
